<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="common/layout">
<head>
    <title>一次性用品列表</title>
    <script th:inline="javascript">
        $(function(){
            Paginator.init(
                    [[${total}]],
                    function(page){
                        var querys={};
                        querys["page"] = page;
                        if([[${key_word}]]){
                            querys["key_word"] = [[${stat_key}]];
                        }
                        var url = "/admin/dishware?" + $.param(querys);
                        self.location.href = url;
                    },
                    [[${page}]]
            );
        });

        function dishwareRemove(id) {
            if (!confirm("确定删除吗？")) {
                return;
            }
            $.post("/admin/dishware/" + id, {_method: "DELETE"}, function (data) {
                if (data.success) {
                    self.location.reload();
                } else {
                    alert(data.message);
                }
            });
        };

    </script>
</head>
<body>
<section layout:fragment="top_menu" style="text-align: right;padding-right: 20px">
    <div>
        <input type="button" class="new_button_yellow input_add" onclick="location.href='/admin/dishware/new'" value="添加">
    </div>
</section>

<section layout:fragment="content">
    <div class="list" style="font-size:0.9em;">
        <table id="list">
            <tr class="header">
                <td>一次性用品名称</td>
                <td>单价</td>
                <td>单位</td>
                <td>自动添加</td>
                <td>操作</td>
            </tr>
            <tbody id="list_body">
            <tr th:each="item,row:${rows}" th:id="${#strings.concat('item_', item.id)}" th:class="${#strings.concat('item_', row.index%2)}">
                <td th:text="${item.name}"></td>
                <td th:text="${item.unitPrice}"></td>
                <td th:text="${item.unit}"></td>
                <td th:text="${item.autoAddStr}"></td>
                <td>
                    <a class="icon-remove" th:href="${#strings.concat('javascript:dishwareRemove(',item.id, ')')}">删除</a>
                    &nbsp;&nbsp;
                    <a class="icon-edit" th:href="${#strings.concat('/admin/dishware/',item.id)}">编辑</a>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="paginator">
            <ul>
                <li><</li>
                <li>1</li>
                <li>2</li>
                <li>3</li>
                <li class="dot">...</li>
                <li>9</li>
                <li>></li>
            </ul>
        </div>
    </div>
</section>

</body>

</html>